/*
 * Copyright (C) 2010 TopCoder Inc., All Rights Reserved.
 */
package com.hercules.xre.protocol.testing.runner;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/**
 * <p>
 * Constants for Protocol Testing.
 * </p>
 * <p>
 * Thread safety: This class is immutable and so thread safe.
 * </p>
 *
 * @author TCSASSEMBLER
 * @version 1.0
 */
public final class Constants {

    /**
     * The session guid.
     */
    public static final String SESSION_GUID;

    /**
     * The log file.
     */
    public static final String LOG_FILE;

    /**
     * The configuration file for sections.
     */
    public static final String SECTIONS_FILE;

    /**
     * The start command file for the testing.
     */
    public static final String START_FILE;

    /**
     * This private constructor prevents to create a new instance.
     */
    private Constants() {
        // empty
    }

    /**
     * Load constants.
     */
    static {
        Properties properties = new Properties();
        FileReader reader = null;
        try {
            reader = new FileReader("conf" + File.separator + "test.properties");
            properties.load(reader);
            SESSION_GUID = properties.getProperty("sessionGUID");
            LOG_FILE = properties.getProperty("logFile");
            SECTIONS_FILE = properties.getProperty("sectionsFile");
            START_FILE = properties.getProperty("startFile");
        } catch (IOException e) {
            throw new RuntimeException("Error during initialization", e);
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }
    }
}